{template header}
<style type="text/css">
    .table-striped td,
    .table-striped th { text-align: center;}
    .table-striped td:nth-child(2) { min-width:100px; max-width: 350px;}
</style>
<a class="btn btn-large btn-link" type="button" href="?c=actMarathon&a=marathoninfo">添加马拉松活动</a>
前段活动地址：{$hosts}/marathonWeb/marathonindex/?m_id=活动ID
<div class="container-fluid">
  <table class="table table-striped">
        <thead>
            <tr>
				<th>活动ID</th>
                <th>标题</th>
                <th>状态</th>
                <th>费用</th>
                <th>里程数</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>编辑</th>
            </tr>
        </thead>
        <tbody>
            {loop $marathonList $k $v}
            <tr>
				<td>{$v['id']}</td>
                <td>{$v['title']}</td>
                <td>{if $v['status'] == 0}未开始{elseif $v['status'] == 1}进行中{else}已结束{/if}</td>
                <td>{$v['charge']}</td>
                <td>{$v['total_mileage']}</td>
                <td>{eval echo date("Y-m-d H:i:s", $v['start_time'])}</td>
                <td>{eval echo date("Y-m-d H:i:s", $v['end_time'])}</td>
                <td>
					<a class="btn btn-edit" href="?c=actMarathon&a=marathoninfo&m_id=$v['id']">编辑</a>
					{if !$v['display']}
						<a class="btn btn-edit enter-set" href="javascript: void(0);" data-id="{$v['id']}">设为活动入口</a>
					{else}
						<a class="btn btn-edit enter-cancel" href="javascript: void(0);" data-id="{$v['id']}">取消活动入口</a>
					{/if}
                </td>
            </tr>
            {/loop}
        </tbody>
    </table>
</div>
<div class="pagination">
    <ul>
        {$pageStr}
    </ul>
</div>
<script type="text/javascript">
	$(function(){
		$('.enter-set').on('click', function(){
			var type =  'set';
			var id	 = $(this).attr('data-id');
			displayModify(id, type);	
		});
		
		$('.enter-cancel').on('click', function(){
			var type =  'cancel';
			var id	 = $(this).attr('data-id');
			displayModify(id, type);	
		});
		
		function displayModify(id, type) {
			$.post(
				'/actMarathon/changeDisplay',
				{'id': id, 'operate': type},
				function(data){
					if (data.code == 0) {
						alert(data.msg); 
						location.reload();
					} else {
						alert(data.msg);
					}
				},
				'json'
			)
		}
	});
</script>
{template footer}
